﻿@using NewLife.Common;
@using NewLife.Cube.Areas.Admin;
@using XCode.DataAccessLayer;
@{
    //Layout = NewLife.Cube.Setting.Current.Layout;

    var dbs = Model as IList<DbItem>;
}
<table class="table table-bordered table-hover table-striped table-condensed">
    <thead>
        <tr>
            <th class="text-center">名称</th>
            <th class="text-center">类型</th>
            <th class="text-center">连接字符串</th>
            <th class="text-center">数据库版本</th>
            <th class="text-center">驱动</th>
            <th class="text-center">驱动版本</th>
            <th class="text-center">实体个数</th>
            <th class="text-center">表个数</th>
            <th class="text-center">备份</th>
            <th class="text-center">备份并压缩</th>
            <th class="text-center">下载表结构</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in dbs)
        {
            var dal = DAL.Create(item.Name);
            var pk = dal.ProtectedKey;

            // 密码需要保密
            var str = pk.Hide(item.ConnStr);
            var str2 = pk.Hide(dal.Db.ConnectionString);

            <tr>
                <td>@item.Name</td>
                <td>@item.Type</td>
                <td style="max-width:600px;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;" title="@str2">@str</td>
                <td>@item.Version</td>
                <td>@item.Driver</td>
                <td>@item.DriverVersion</td>
                <td class="text-center">@Html.ActionLink(item.Entities + "", "ShowEntities", new { Name = item.Name })</td>
                <td class="text-center">@Html.ActionLink(item.Tables + "", "ShowTables", new { Name = item.Name })</td>
                <td>@Html.ActionLink("备份", "Backup", new { Name = item.Name })，共 @item.Backups.ToString("n0")个</td>
                <td>@Html.ActionLink("备份并压缩", "BackupAndCompress", new { Name = item.Name })</td>
                <td class="text-center">@Html.ActionLink("下载", "Download", new { Name = item.Name })</td>
            </tr>
        }
    </tbody>
</table>